package services.impl;

import java.sql.SQLException;
import java.util.List;

import dao.GoodsDao;
import dao.impl.GoodsDaoImpl;
import entity.Goods;
import services.GoodsService;

public class GoodsServiceImpl implements GoodsService{
	private GoodsDao goodsDao;

	public GoodsServiceImpl() {
		goodsDao = new GoodsDaoImpl();
	}

	@Override
	public List<Goods> getGoodsByName(String name) {
		List<Goods> goodsList = null;
		
		try {
			if(name.equals("") || name.length()==0) {
				goodsList = goodsDao.getgoodsList();
			}else {
				goodsList = goodsDao.getgoods(name);
			}
			
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return goodsList;
	}

	@Override
	public List<Goods> getGoods() {
		List<Goods> goodsList = null;
		try {
			goodsList = goodsDao.getgoodsList();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return goodsList;
	}

}